﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Reporting.WebForms;
using System.Configuration;
using KPIReport.Library.DataAccess.Administration.Catalog;

public partial class reports_reportViewer : System.Web.UI.Page
{
    private string namaReport = string.Empty;
    private ReportRepo ReportDal = new ReportRepo(ConfigurationManager.ConnectionStrings["KPIReportConn"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["namaReport"] != null)
            namaReport = Request.Params["namaReport"].ToString();

        if (!IsPostBack)
        {
            switch (namaReport)
            {
                case ("ReportMustSellListSS"):
                    LoadReportMustSellListSS();
                    break;
                
                default:
                    break;
            }
        }
    }

    private void LoadReportMustSellListSS()
    {
        
        try
        {


            DataTable dt = ReportDal.GetReportMustSellListSS();


            rsViewer.Reset();
            rsViewer.LocalReport.ReportPath = Server.MapPath("~/reportviewer/rptMustSellListSS.rdlc");
            ReportDataSource rds = new ReportDataSource();
            rds.Name = "DataSet1";
            rds.Value = dt;

            //ReportParameter[] param = new ReportParameter[1];
            //param[0] = new ReportParameter("dateHeader", "PER - " + tglPeriodeReport);


            //rsViewer.LocalReport.SetParameters(param);

            rsViewer.LocalReport.DataSources.Clear();
            rsViewer.LocalReport.DataSources.Add(rds);
            rsViewer.LocalReport.Refresh();

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {

        }
    }
}